package com.valley.dream.tihai.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.valley.dream.tihai.MainActivity;
import com.valley.dream.tihai.R;
import com.valley.dream.tihai.model.dto.ProblemParcelable;
import com.valley.dream.tihai.model.entity.Problem;
import com.valley.dream.tihai.presenter.IProblemPresenter;
import com.valley.dream.tihai.presenter.impl.ProblemPresenterImpl;

public class SubmitProblemActivity extends AppCompatActivity {

    IProblemPresenter iProblemPresenter = new ProblemPresenterImpl();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_submit_problem);
    }

    public void createProblem(View view) {
        Intent intent = getIntent();
        ProblemParcelable problemParcelable = intent.getParcelableExtra("problem");
        Problem problem = new Problem();
        problem.setUserId(problemParcelable.getUserId());
        problem.setTypeId(problemParcelable.getTypeId());
        iProblemPresenter.createProblem(this, problem);
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}
